// Haxzs Audio Server
// made by omghaxzs
// 2010

#ifndef CLIENT_H
#define CLIENT_H

#include "main.h"

#define CLIENT_TYPE_SOURCE 1
#define CLIENT_TYPE_LISTENER 2

using boost::asio::ip::tcp;

struct client_info
{
	std::string ip, agent;
};

class client : boost::noncopyable {

private:
	boost::thread m_Thread;
	int clientType;
public:
	bool cachefull, newdata, connected, okaytosend;
	int recvbuflen, sendbuflen, errorcode, bytes, id;
	const int* buffer_len;
	tcp::socket clientsocket;
	std::string recvbuf, sendbuf, cache, part, tosend, ident, format, rate, ip;
	client_info info;

	client(); // Constructor

	inline int  getClientType() {return clientType;};
	inline void setClientType(int cType) { clientType = cType;};
	
	void start();
	void communicate();
	void sendMsg(std::string);
	void sendData(char data[]);
	void disconnect();
	void processCache(std::string);
	void sendSourceData();

	std::string recvMsg();
	std::string recvData();
};

#endif